//
//  SZZViewController.swift
//  SZZweibo
//
//  Created by 申壮壮 on 16/8/10.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class SZZViewController: UIViewController {
    
    //判断是否登录
    var isLogin: Bool = false
    
    
    //访客视图
    var visitorView: SZZVisitorView?
    
    override func loadView() {
        
        if isLogin{
            
            super.loadView()
            
        }else{
            
            setupVisitorView()
        }
        
    }
    
    //设置访客视图
    func  setupVisitorView(){
        
        setupNav()
        
        visitorView = SZZVisitorView()
        //闭包的实例化
        visitorView?.closure = {
            
           self.loginAction()
            
        }
        
        view = visitorView
    }
    //设置导航
    func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")

    }
    //监听方法
    func loginAction(){
        
        let oauthVc = SZZOAuthViewController()
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
}
